package com.is.dmd.base;

import android.support.v7.widget.Toolbar;
import android.widget.Toast;

import com.is.dmd.R;
import com.is.dmd.DMDApplication;
import com.is.dmd.mvp.view.BaseView;
import com.is.base.BaseAppCompatActivity;
import com.is.common.netstatus.NetUtils;

import butterknife.ButterKnife;

/**
 *
 */
public abstract class BaseActivity extends BaseAppCompatActivity implements BaseView {

    protected Toolbar mToolbar;


    protected DMDApplication getYHGApplication() {
        return (DMDApplication) getApplication();
    }

    /**
     * 是否设置状态栏颜色
     * @return
     */
    protected abstract boolean isApplySystemBarColor();

    @Override
    public void setContentView(int layoutResID) {
        super.setContentView(layoutResID);
        mToolbar = ButterKnife.findById(this, R.id.common_toolbar);
        if (null != mToolbar) {

            setSupportActionBar(mToolbar);
            getSupportActionBar().setHomeButtonEnabled(true);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
        if (isApplySystemBarColor()){
            setSystemBarTintColor();
        }
    }
    @Override
    protected void onNetworkConnected(NetUtils.NetType type) {
        if (type.name().equals("WIFI")){

        }else if (type.name().equals("CMNET")){
        }else if (type.name().equals("CMWAP")){
        }else if (type.name().equals("NONE")){

        }
        showToast("正在连接"+type.name()+"网络");
    }

    @Override
    protected void onNetworkDisConnected() {
        showToast("网络连接断开");
    }

    @Override
    public void showError(String msg) {

    }

    @Override
    public void showException(String msg) {

    }

    @Override
    public void showLoading(String msg) {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showToast(String msg) {
        Toast.makeText(mContext,msg,Toast.LENGTH_SHORT).show();
    }
}
